package csc.fresher.view;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import csc.fresher.entity.CustomerAccountOverall;

public class CustomerOverallDataModel extends ListDataModel<CustomerAccountOverall> implements
		SelectableDataModel<CustomerAccountOverall> {
	
	public CustomerOverallDataModel() {
		
	}
	
	public CustomerOverallDataModel(List<CustomerAccountOverall> data) {
		super(data);
	}

	@Override
	public CustomerAccountOverall getRowData(String rowKey) {
		List<CustomerAccountOverall> customers = (List<CustomerAccountOverall>) getWrappedData();
		
		for(CustomerAccountOverall c : customers) {
			if(c.getAccountNumber() == Long.parseLong(rowKey)) {
				return c;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(CustomerAccountOverall customer) {
		return customer.getAccountNumber();
	}

}
